HAL FDCAN Functions

HAL FDCAN Functions

group FDCAN_Exported_Functions

Functions

stm32_utils_fdcan_status_t STM32_UTILS_FDCAN_ComputeBitTiming ( const stm32_utils_fdcan_input_bus_param_t * p_bus_param , stm32_utils_fdcan_bit_timing_type_t bit_timing_type , stm32_utils_fdcan_bit_timing_t * p_output_bit_timing , stm32_utils_fdcan_output_config_t * p_output_config )

Compute the FDCAN nominal or data bit timings from input bus parameters.

Note

The given maximum bitrate tolerance takes into account integer rounding, and guarantees that the bitrate deviation is always below or equal to the maximum given.

Note

The stm32_utils_fdcan_bit_timing_t:sync_jump_width parameter is highly dependent on the specific characteristics of the CAN network, such as the network’s length, the propagation delay, the oscillator tolerance, etc. Therefore, this function will always set it to the default minimal value 1. This value can be fine-tuned by the end user if synchronization issues are observed.

Parameters :
Return values :
  • STM32_UTILS_FDCAN_OK – Configuration matching the bus parameters was found.

  • STM32_UTILS_FDCAN_ERROR – No configuration matching the bus parameters was found. Data output must be discarded.

  • STM32_UTILS_FDCAN_INVALID_PARAM – One or more pointer parameters are NULL, the FDCAN kernel clock or desired bitrate is zero, the sample point is greater than 1000 per mille, or the bit timing type is invalid.

stm32_utils_fdcan_status_t STM32_UTILS_FDCAN_ComputeBitrate ( const stm32_utils_fdcan_bit_timing_t * p_bit_timing , uint32_t fdcan_clk_khz , stm32_utils_fdcan_output_config_t * p_output_config )

Compute the FDCAN nominal or data bitrate and sampling point from bit timing parameters.

Parameters :
Return values :
  • STM32_UTILS_FDCAN_OK – Operation completed successfully.

  • STM32_UTILS_FDCAN_INVALID_PARAM – One or more pointer parameters are NULL or the bit timing prescaler is zero.

Initialization and de-initialization functions

group FDCAN_Exported_Functions_Group1

A set of functions allowing to initialize and deinitialize the FDCAN peripheral:

Functions

hal_status_t HAL_FDCAN_Init ( hal_fdcan_handle_t * hfdcan , hal_fdcan_t instance )

Initializes the FDCAN peripheral according to the associated handle.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – hfdcan is NULL.

  • HAL_ERROR – HAL FDCAN semaphore creation has failed (USE_HAL_MUTEX is set to 1).

void HAL_FDCAN_DeInit ( hal_fdcan_handle_t * hfdcan )

Deinitialize the FDCAN driver for the given handle and disable the peripheral.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Power management functions

group FDCAN_Exported_Functions_Group2

A set of functions allowing to enter and exit sleep mode for the FDCAN peripheral:

Functions

hal_status_t HAL_FDCAN_EnterPowerDownMode ( hal_fdcan_handle_t * hfdcan )

Sets the FDCAN peripheral into power down (sleep) mode.

Note

In this mode, the FDCAN peripheral stops all bus activity, disables its clock, and reduces power consumption. The FDCAN can be woken up by a dedicated wakeup event or by software. This mode is specific to the FDCAN peripheral and is not to be confused with the STM32 MCU stop or standby.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – FDCAN cannot be set in power down mode.

hal_status_t HAL_FDCAN_ExitPowerDownMode ( hal_fdcan_handle_t * hfdcan )

Exit the FDCAN peripheral power down mode (sleep mode).

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – FDCAN cannot leave the power down mode.

Configuration functions

group FDCAN_Exported_Functions_Group3

There are two categories of HAL configuration set of functions for the peripheral configuration:

  • Global configuration functions that set or get the overall peripheral configuration.

  • Unitary configuration functions that modify or retrieve individual configuration items.

Items that can alter other config parameters must not be handled within unitary set of functions.

Note

Some configuration functions require the FDCAN peripheral to be in the IDLE state before being called. However, several configuration functions are allowed to be called when the peripheral is in ACTIVE or IDLE states, as these configurations can be applied dynamically without stopping the peripheral.

Functions

hal_status_t HAL_FDCAN_SetConfig ( hal_fdcan_handle_t * hfdcan , const hal_fdcan_config_t * p_config )

Configures the FDCAN according to the user parameters.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_config – Pointer to the configuration structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_config is NULL.

  • HAL_ERROR – FDCAN cannot leave the power down mode..

void HAL_FDCAN_GetConfig ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_config_t * p_config )

Get the FDCAN global configuration.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_config – Pointer to the configuration structure to be filled with current configuration.

hal_status_t HAL_FDCAN_SetNominalBitTiming ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_nominal_bit_timing_t * p_nominal_bit_timing )

Set the FDCAN nominal bit timing configuration.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_nominal_bit_timing – Pointer to nominal bit timing structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_nominal_bit_timing is NULL.

void HAL_FDCAN_GetNominalBitTiming ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_nominal_bit_timing_t * p_nominal_bit_timing )

Get the FDCAN nominal bit timing configuration.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_nominal_bit_timing – Pointer to the nominal bit timing structure to be filled with current configuration.

hal_status_t HAL_FDCAN_SetDataBitTiming ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_data_bit_timing_t * p_data_bit_timing )

Set the FDCAN data bit timing configuration.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_data_bit_timing – Pointer to data bit timing structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_data_bit_timing is NULL.

void HAL_FDCAN_GetDataBitTiming ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_data_bit_timing_t * p_data_bit_timing )

Get the FDCAN data bit timing configuration.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_data_bit_timing – Pointer to the data bit timing structure to be filled with current configuration.

hal_status_t HAL_FDCAN_SetFilter ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_filter_t * p_filter_config )

Configure the FDCAN reception filter according to the user parameters.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_filter_config – Pointer to a filter structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_filter_config is NULL.

void HAL_FDCAN_GetFilter ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_filter_t * p_filter_config , uint32_t filter_index , hal_fdcan_id_type_t id_type )

Configure the FDCAN reception filter according to the specified parameters in the hal_fdcan_filter_t structure.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_filter_config – Pointer to a filter structure to be filled with current configuration.

  • filter_index – Index of the filter to be set.

  • id_type – Filter type, for standard or extended ID.

hal_status_t HAL_FDCAN_SetGlobalFilter ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_global_filter_config_t * p_global_filter_config )

Configure the FDCAN global filter.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle structure.

  • p_global_filter_config – Pointer to a global filter structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_global_filter_config is NULL.

void HAL_FDCAN_GetGlobalFilter ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_global_filter_config_t * p_global_filter_config )

Get the FDCAN global filter.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_global_filter_config – Pointer to a global filter structure.

hal_status_t HAL_FDCAN_SetExtendedIdMask ( const hal_fdcan_handle_t * hfdcan , uint32_t mask )

Set the extended ID mask value.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • mask – Value of the extended ID mask, this parameter must be a number between 0 and 0x1FFFFFFF.

Return values :

HAL_OK – Operation completed successfully.

uint32_t HAL_FDCAN_GetExtendedIdMask ( const hal_fdcan_handle_t * hfdcan )

Get the extended ID mask value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

uint32_t Current extended ID mask (0x00000000..0xFFFFFFFF).

hal_status_t HAL_FDCAN_SetClockDivider ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_clock_divider_t clock_divider )

Set the FDCAN clock divider value.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • clock_divider – Value of the FDCAN clock divider.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_clock_divider_t HAL_FDCAN_GetClockDivider ( const hal_fdcan_handle_t * hfdcan )

Get the clock divider for FDCAN.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current FDCAN kernel clock divider.

hal_status_t HAL_FDCAN_SetRxFifoOverwrite ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_rx_location_t rx_location_idx , hal_fdcan_rx_fifo_mode_t operation_mode )

Configure the Rx FIFO operation mode.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • rx_location_idx – Rx FIFO selector.

  • operation_mode – Operation mode.

Return values :

HAL_OK – Operation completed successfully.

void HAL_FDCAN_GetRxFifoOverwrite ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_rx_location_t rx_location_idx , hal_fdcan_rx_fifo_mode_t * p_operation_mode )

Get the Rx FIFO operation mode.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • rx_location_idx – Rx FIFO selector.

  • p_operation_mode – Pointer to the selected Rx FIFO operation mode value.

hal_status_t HAL_FDCAN_SetRamWatchdog ( const hal_fdcan_handle_t * hfdcan , uint8_t counter_start_value )

Configure the RAM watchdog.

Note

With the reset value of 0x00 the counter is disabled.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • counter_start_value – Start value of the message RAM watchdog counter, this parameter must be a number between 0x00 and 0xFF.

Return values :

HAL_OK – Operation completed successfully.

uint8_t HAL_FDCAN_GetRamWatchdog ( const hal_fdcan_handle_t * hfdcan )

Get the current RAM watchdog counter - not the configured value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

uint8_t Current message RAM watchdog counter value (0x00..0xFF).

hal_status_t HAL_FDCAN_SetConfigTimestampCounter ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_timestamp_config_t * p_timestamp_config )

Configure the timestamp counter.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_timestamp_config – Pointer to a timestamp configuration structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_timestamp_config is NULL.

void HAL_FDCAN_GetConfigTimestampCounter ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_timestamp_config_t * p_timestamp_config )

Get the timestamp counter configuration.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_timestamp_config – Pointer to a timestamp configuration structure.

hal_status_t HAL_FDCAN_SetConfigTimeoutCounter ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_timeout_config_t * p_timeout_param )

Configure the timeout counter.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_timeout_param – Pointer to a timeout configuration structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_timeout_param is NULL.

void HAL_FDCAN_GetConfigTimeoutCounter ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_timeout_config_t * p_timeout_param )

Get the timeout counter configuration.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_timeout_param – Pointer to a timeout configuration structure.

hal_status_t HAL_FDCAN_EnableTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Enable the timeout counter.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Disable the timeout counter.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_timeout_counter_status_t HAL_FDCAN_IsEnabledTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Check timeout counter status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current timeout counter status.

hal_status_t HAL_FDCAN_SetConfigTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan , const hal_fdcan_tx_delay_comp_config_t * p_tx_delay_param )

Configure the transmitter delay compensation.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_tx_delay_param – Pointer to a Tx delay compensation structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_tx_delay_param is NULL.

void HAL_FDCAN_GetConfigTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_delay_comp_config_t * p_tx_delay_param )

Get the transmitter delay compensation offset.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_tx_delay_param – Pointer to a Tx delay compensation structure.

hal_status_t HAL_FDCAN_EnableTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan )

Enable the transmitter delay compensation.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan )

Disable the transmitter delay compensation.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_tx_delay_comp_status_t HAL_FDCAN_IsEnabledTxDelayCompensation ( const hal_fdcan_handle_t * hfdcan )

Check transmitter delay compensation status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current transmitter delay compensation status.

hal_status_t HAL_FDCAN_EnableISOMode ( const hal_fdcan_handle_t * hfdcan )

Enable ISO 11898-1 protocol mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableISOMode ( const hal_fdcan_handle_t * hfdcan )

Disable ISO 11898-1 protocol mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_iso_mode_status_t HAL_FDCAN_IsEnabledISOMode ( const hal_fdcan_handle_t * hfdcan )

Check ISO 11898-1 protocol mode status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current ISO mode status.

hal_status_t HAL_FDCAN_EnableEdgeFiltering ( const hal_fdcan_handle_t * hfdcan )

Enable edge filtering during bus integration.

Note

Two consecutive dominant tq’s are required to detect an edge for hard synchronization.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableEdgeFiltering ( const hal_fdcan_handle_t * hfdcan )

Disable edge filtering during bus integration.

Note

One dominant tq is required to detect an edge for hard synchronization.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_edge_filtering_status_t HAL_FDCAN_IsEnabledEdgeFiltering ( const hal_fdcan_handle_t * hfdcan )

Check edge filtering during bus integration status.

Note

One dominant tq is required to detect an edge for hard synchronization.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current edge filtering status.

hal_status_t HAL_FDCAN_SetMode ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_mode_t mode )

Set the FDCAN mode.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_mode_t HAL_FDCAN_GetMode ( const hal_fdcan_handle_t * hfdcan )

Get the FDCAN mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current FDCAN mode.

hal_status_t HAL_FDCAN_EnableRestrictedOperationMode ( const hal_fdcan_handle_t * hfdcan )

Enable the restricted operation mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – LoopBack mode is already used and cannot be combined with restricted operation mode.

hal_status_t HAL_FDCAN_DisableRestrictedOperationMode ( const hal_fdcan_handle_t * hfdcan )

Disable the restricted operation mode.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_restricted_op_mode_status_t HAL_FDCAN_IsEnabledRestrictedOperationMode ( const hal_fdcan_handle_t * hfdcan )

Check the FDCAN restricted operation mode status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current restricted operation mode status.

hal_status_t HAL_FDCAN_SetFrameFormat ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_frame_format_t frame_format )

Set the frame format.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • frame_format – The frame format to set.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_frame_format_t HAL_FDCAN_GetFrameFormat ( const hal_fdcan_handle_t * hfdcan )

Get the frame format.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current frame format.

hal_status_t HAL_FDCAN_EnableAutoRetransmission ( const hal_fdcan_handle_t * hfdcan )

Enable automatic retransmission of messages.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableAutoRetransmission ( const hal_fdcan_handle_t * hfdcan )

Disable auto retransmission of messages.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_auto_retransmission_state_t HAL_FDCAN_IsEnabledAutoRetransmission ( const hal_fdcan_handle_t * hfdcan )

Get automatic retransmission state.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current auto retransmission setting.

hal_status_t HAL_FDCAN_EnableTransmitPause ( const hal_fdcan_handle_t * hfdcan )

Enable transmit pause.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTransmitPause ( const hal_fdcan_handle_t * hfdcan )

Disable transmit pause.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_transmit_pause_state_t HAL_FDCAN_IsEnabledTransmitPause ( const hal_fdcan_handle_t * hfdcan )

Get the transmit pause state.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current transmit pause setting.

hal_status_t HAL_FDCAN_EnableProtocolException ( const hal_fdcan_handle_t * hfdcan )

Enable protocol exception.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableProtocolException ( const hal_fdcan_handle_t * hfdcan )

Disable protocol exception.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_protocol_exception_state_t HAL_FDCAN_IsEnabledProtocolException ( const hal_fdcan_handle_t * hfdcan )

Get the protocol exception status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current protocol exception setting.

hal_status_t HAL_FDCAN_SetTxMode ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_mode_t tx_mode )

Set the transmission FIFO/Queue mode.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • tx_mode – Transmission mode to configure.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_tx_mode_t HAL_FDCAN_GetTxMode ( const hal_fdcan_handle_t * hfdcan )

Get the transmission FIFO/Queue mode configuration.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current Tx FIFO/queue mode.

uint32_t HAL_FDCAN_GetClockFreq ( const hal_fdcan_handle_t * hfdcan )

Return the peripheral clock frequency for FDCAN.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

uint32_t Current clock frequency(Hz) (0x00000000..0xFFFFFFFF). 0U if FDCAN is not configured or not ready.

Callback registration functions

group FDCAN_Exported_Functions_Group4

A set of functions allowing to register custom callback handlers for specific FDCAN events:

These registration functions must be called when the FDCAN handle is in the INIT or IDLE state. The default callbacks are weak functions that can be overridden or replaced by these registration APIs.

Functions

hal_status_t HAL_FDCAN_RegisterTxEventFifoCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_fifo_cb_t p_callback )

Register Tx event FIFO callback to be used instead of the weak HAL_FDCAN_TxEventFifoCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Tx event FIFO callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterRxFifo0Callback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_fifo_cb_t p_callback )

Register Rx FIFO 0 callback to be used instead of the weak HAL_FDCAN_RxFifo0Callback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Rx FIFO 0 callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterRxFifo1Callback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_fifo_cb_t p_callback )

Register Rx FIFO 1 callback to be used instead of the weak HAL_FDCAN_RxFifo1Callback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Rx FIFO 1 callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterTxFifoEmptyCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_cb_t p_callback )

Register Tx FIFO empty callback to be used instead of the weak HAL_FDCAN_TxFifoEmptyCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Tx FIFO empty callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterTxBufferCompleteCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_buffer_cb_t p_callback )

Register Tx buffer complete callback to be used instead of the weak HAL_FDCAN_TxBufferCompleteCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Tx buffer complete callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterTxBufferAbortCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_buffer_cb_t p_callback )

Register Tx buffer abort callback to be used instead of the weak HAL_FDCAN_TxBufferAbortCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the Tx buffer abort callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterHighPriorityMessageCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_cb_t p_callback )

Register high priority message callback to be used instead of the weak HAL_FDCAN_HighPriorityMessageCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the high priority message callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterTimestampWraparoundCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_cb_t p_callback )

Register timestamp wrap around callback to be used instead of the weak HAL_FDCAN_TimestampWraparoundCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the timestamp wrap around callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

hal_status_t HAL_FDCAN_RegisterErrorCallback ( hal_fdcan_handle_t * hfdcan , hal_fdcan_cb_t p_callback )

Register error callback to be used instead of the weak HAL_FDCAN_ErrorCallback() predefined callback.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_callback – Pointer to the FDCAN error callback function.

Return values :
  • HAL_OK – Registering completed successfully.

  • HAL_INVALID_PARAM – p_callback is NULL.

Control functions

group FDCAN_Exported_Functions_Group5

A set of functions allowing to control the peripheral and initiate an operation on the bus:

Functions

hal_status_t HAL_FDCAN_Start ( hal_fdcan_handle_t * hfdcan )

Start the FDCAN module.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – hfdcan is NULL.

  • HAL_BUSY – There is ongoing process.

hal_status_t HAL_FDCAN_Stop ( hal_fdcan_handle_t * hfdcan )

Stop the FDCAN module and enable access to configuration registers.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – hfdcan is NULL.

  • HAL_ERROR – FDCAN cannot leave the power down mode.

hal_status_t HAL_FDCAN_ReqTransmitMsgFromFIFOQ ( hal_fdcan_handle_t * hfdcan , const hal_fdcan_tx_header_t * p_tx_element_header , const uint8_t * p_tx_data )

Add a message to the Tx FIFO/Queue and activate the corresponding transmission request.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_tx_element_header – Pointer to a Tx element header structure.

  • p_tx_data – Pointer to a buffer containing the payload of the Tx frame.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_tx_element_header or p_tx_data are NULL.

  • HAL_ERROR – The Tx FIFO/Queue is full

hal_fdcan_fifo_status_t HAL_FDCAN_GetTxFifoStatus ( const hal_fdcan_handle_t * hfdcan )

Get the Tx FIFO/Queue status.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current FIFO/Queue status.

uint32_t HAL_FDCAN_GetLatestTxFifoQRequestBuffer ( const hal_fdcan_handle_t * hfdcan )

Get the Tx buffer index of latest Tx FIFO/Queue request.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

uint32_t Current index of last Tx FIFO/Queue request (0x00000000..0xFFFFFFFF). 0U if No Tx submitted request.

hal_fdcan_tx_fifo_free_level_t HAL_FDCAN_GetTxFifoFreeLevel ( const hal_fdcan_handle_t * hfdcan )

Return the Tx FIFO free level - number of consecutive free Tx FIFO elements starting from Tx FIFO get_index.

Warning

This function is relevant only when the Tx FIFO operates in FIFO mode. In Queue mode, the Tx FIFO free level is always HAL_FDCAN_TX_FIFO_FREE_LEVEL_0.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current Tx FIFO free level.

hal_status_t HAL_FDCAN_ReqAbortOfTxBuffer ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffer_idx )

Abort transmission request.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_GetTxEvent ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_tx_evt_fifo_header_t * p_tx_event )

Get a FDCAN Tx event from the Tx event FIFO zone into the message RAM.

Parameters :
Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_tx_event is NULL.

  • HAL_ERROR – FIFO is empty or no RAM was allocated for it.

void HAL_FDCAN_GetTxEventFifoFillLevel ( const hal_fdcan_handle_t * hfdcan , uint32_t * p_fill_level )

Return the number of unread Tx event FIFO elements.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_fill_level – Pointer to variable to receive the current fill level.

hal_fdcan_tx_buffer_status_t HAL_FDCAN_GetTxBufferMessageStatus ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffer_idx )

Check if a transmission request is pending on any of the selected Tx buffers.

Parameters :
Returns :

Current Tx buffer pending status.

hal_status_t HAL_FDCAN_GetReceivedMessage ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_rx_location_t rx_location_idx , hal_fdcan_rx_header_t * p_rx_header , uint8_t * p_rx_data )

Get a FDCAN frame from the Rx FIFO zone into the message RAM.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • rx_location_idx – Location of received message to read.

  • p_rx_header – Pointer to an Rx element header structure to be filled.

  • p_rx_data – Pointer to a buffer where the payload of the Rx message has to be stored.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_rx_header or p_rx_data are NULL.

  • HAL_ERROR – Rx FIFO empty.

void HAL_FDCAN_GetRxFifoFillLevel ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_rx_location_t rx_location_idx , uint32_t * p_fill_level )

Get the fill level of the specified Rx FIFO.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • rx_location_idx – Rx FIFO selector.

  • p_fill_level – Pointer to variable to receive the current fill level.

uint16_t HAL_FDCAN_GetTimestampCounter ( const hal_fdcan_handle_t * hfdcan )

Get the timestamp counter value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

uint16_t Current timestamp counter value (0x0000..0xFFFF).

hal_status_t HAL_FDCAN_ResetTimestampCounter ( const hal_fdcan_handle_t * hfdcan )

Reset the timestamp counter to zero.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – Timestamp counter source is not internal.

uint16_t HAL_FDCAN_GetTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Get the timeout counter value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

uint16_t Current timeout counter value (0x0000..0xFFFF).

hal_status_t HAL_FDCAN_ResetTimeoutCounter ( const hal_fdcan_handle_t * hfdcan )

Reset the timeout counter to its start value.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – Timeout counter source is not continuous.

hal_status_t HAL_FDCAN_GetHighPriorityMessageStatus ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_high_prio_msg_status_t * p_hp_msg_status )

Get the high priority message status.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_hp_msg_status – Pointer to a high priority message status structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_hp_msg_status is NULL.

hal_status_t HAL_FDCAN_GetProtocolStatus ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_protocol_status_t * p_protocol_status )

Get the protocol status.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_protocol_status – Pointer to a protocol status structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_protocol_status is NULL.

hal_status_t HAL_FDCAN_GetErrorCounters ( const hal_fdcan_handle_t * hfdcan , hal_fdcan_error_counters_t * p_error_counters )

Get the error counter values.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • p_error_counters – Pointer to an error counters structure.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_INVALID_PARAM – p_error_counters is NULL.

hal_status_t HAL_FDCAN_Recover ( const hal_fdcan_handle_t * hfdcan )

Recover the FDCAN bus-off error.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :

HAL_OK – Operation completed successfully.

Interrupts management functions

group FDCAN_Exported_Functions_Group6

A set of functions allowing to deal with interruptions of the peripheral:

The FDCAN interrupt handler processes events in the following order:

  • Error events (bus-off, error passive, warning, protocol errors, RAM watchdog, etc).

  • High priority message event.

  • Rx FIFO 0 events (new message, full, message lost).

  • Rx FIFO 1 events (new message, full, message lost).

  • Tx Event FIFO events (new entry, full, element lost).

  • Tx FIFO empty event.

  • Transmission complete and transmission cancellation events.

  • Timestamp wraparound event.

The following callbacks are triggered by the FDCAN interrupt handler when the corresponding event occurs and the relevant interrupts are enabled.

The table below lists the additional, callback-specific API(s) required to trigger each callback:

The actual callback triggered depends on the enabled interrupts and the process API in use.

Interrupt Group

Representative Flags

Recommended Line

Reason

HAL_FDCAN_IT_GROUP_RX_FIFO_0

RF0N/RF0F/RF0L

Line 1

Latency critical Rx path

HAL_FDCAN_IT_GROUP_RX_FIFO_1

RF1N/RF1F/RF1L

Line 1

Latency critical Rx path

HAL_FDCAN_IT_GROUP_STATUS_MSG

HPM/TC/TCF

Line 1

Prioritize HPM latency

HAL_FDCAN_IT_GROUP_MISC

TSW/MRAF/TOO

Line 1

Prioritize MRAF handling

HAL_FDCAN_IT_GROUP_TX_FIFO_ERROR

TFE/TEFN/TEFF/TEFL

Line 0

Tx service and logging

HAL_FDCAN_IT_GROUP_BIT_LINE_ERROR

ELO/EP

Line 0

Diagnostic

HAL_FDCAN_IT_GROUP_PROTOCOL_ERROR

EW/BO/WDI/PEA/PED/ARA

Line 0

Diagnostic and recovery

Note

For all callbacks below, the following HAL APIs must be called as part of the initialization sequence:

Note

HAL_FDCAN_ErrorCallback is called for any error event, including bus errors, protocol errors, access errors, or timeouts.

Note

Recommended interrupt group dispatching when using HAL_FDCAN_SetInterruptGroupsToLine() with dual-line NVIC integration:

Note

NVIC does not give interrupt line 1 a higher priority than line 0 by itself. The effective priority remains application-defined through the NVIC configuration of the IRQs serving FDCANx_IT0 and FDCANx_IT1. When following the recommendations above, assign FDCANx_IT1 a higher NVIC priority than FDCANx_IT0, that is, use a lower priority value for FDCANx_IT1.

Note

For dual-line NVIC integration, prefer HAL_FDCAN_Line0_IRQHandler() and HAL_FDCAN_Line1_IRQHandler() to get line-focused interrupt dispatching, clearer event attribution, and improved ISR readability.

Functions

void HAL_FDCAN_IRQHandler ( hal_fdcan_handle_t * hfdcan )

Processes all enabled FDCAN interrupt requests (line-agnostic behavior).

Warning

Use HAL_FDCAN_Line0_IRQHandler() / HAL_FDCAN_Line1_IRQHandler() instead of this function when line-specific interrupt dispatching is required.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

void HAL_FDCAN_Line0_IRQHandler ( hal_fdcan_handle_t * hfdcan )

Processes only line 0 mapped and enabled FDCAN interrupt requests.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

void HAL_FDCAN_Line1_IRQHandler ( hal_fdcan_handle_t * hfdcan )

Processes only line 1 mapped and enabled FDCAN interrupt requests.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

hal_status_t HAL_FDCAN_EnableInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupts )

Enable the interrupts.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • interrupts – Interrupt signal(s) to enable, can be OR-ed with different interrupt signals. This parameter can be any combination of FDCAN interrupt sources.

Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupts )

Disable the interrupts.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • interrupts – Interrupt signal(s) to disable - can be OR-ed with other interrupt signals. This parameter can be any combination of FDCAN interrupt sources.

Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_it_status_t HAL_FDCAN_IsEnabledInterrupt ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupt )

Check the interrupt status. Apply to one single interrupt signal.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • interrupt – Interrupt signal to check. Only one single interrupt signal can be checked at a time. This parameter must be one unique sample of FDCAN interrupt sources.

Returns :

Current interrupt status.

hal_status_t HAL_FDCAN_EnableTxBufferCompleteInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffers_idx )

Enable the transmission buffer complete interrupt.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTxBufferCompleteInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffers_idx )

Disable the transmission buffer complete interrupt.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_it_tx_buffer_complete_status_t HAL_FDCAN_IsEnabledTxBufferCompleteInterrupt ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffer_idx )

Check the status of the buffer connected to transmission complete interrupt.

Parameters :
Returns :

Current Tx buffer transmission complete interrupt status.

hal_status_t HAL_FDCAN_EnableTxBufferCancellationInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffers_idx )

Enable the transmission cancellation finished interrupt.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableTxBufferCancellationInterrupts ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffers_idx )

Disable the transmission cancellation finished interrupt.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_it_tx_buffer_abort_status_t HAL_FDCAN_IsEnabledTxBufferCancellationInterrupt ( const hal_fdcan_handle_t * hfdcan , uint32_t tx_buffer_idx )

Check the status of the buffer connected to transmission cancellation finished interrupt.

Parameters :
Returns :

Current Tx buffer abort finished interrupt status.

hal_status_t HAL_FDCAN_SetInterruptGroupsToLine ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupt_groups , uint32_t it_line )

Assign the interrupt group(s) to an interrupt line.

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • interrupt_groups – Interrupt group(s) to connect to the given interrupt line. This parameter can be any combination of FDCAN interrupt groups.

  • it_line – Indicates which interrupt line must be assigned to the interrupt groups. This parameter must be one unique item of FDCAN interrupt lines.

Return values :

HAL_OK – Operation completed successfully.

uint32_t HAL_FDCAN_GetLineFromInterruptGroup ( const hal_fdcan_handle_t * hfdcan , uint32_t interrupt_group )

Get the interrupt line assigned to an interrupt group - applies to a single interrupt group.

Parameters :
Return values :
  • HAL_FDCAN_IT_LINE_0 – Interrupt group is assigned to line 0.

  • HAL_FDCAN_IT_LINE_1 – Interrupt group is assigned to line 1.

hal_status_t HAL_FDCAN_EnableInterruptLines ( const hal_fdcan_handle_t * hfdcan , uint32_t it_lines )

Enable the interrupt line.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_status_t HAL_FDCAN_DisableInterruptLines ( const hal_fdcan_handle_t * hfdcan , uint32_t it_lines )

Disable the interrupt lines.

Parameters :
Return values :

HAL_OK – Operation completed successfully.

hal_fdcan_it_lines_status_t HAL_FDCAN_IsEnabledInterruptLine ( const hal_fdcan_handle_t * hfdcan , uint32_t it_line )

Check the interrupt line status.

Parameters :
Returns :

Current interrupt lines status.

Weak callback functions

group FDCAN_Exported_Functions_Group7

A set of weak functions if USE_HAL_FDCAN_REGISTER_CALLBACKS is set to 0 (or custom callbacks functions if USE_HAL_FDCAN_REGISTER_CALLBACKS is set to 1) which are used to asynchronously informed the application in non-blocking modes:

Functions

void HAL_FDCAN_TxEventFifoCallback ( hal_fdcan_handle_t * hfdcan , uint32_t tx_event_fifo_interrupts )

Tx event callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
void HAL_FDCAN_RxFifo0Callback ( hal_fdcan_handle_t * hfdcan , uint32_t rx_fifo0_interrupts )

Rx FIFO 0 callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
void HAL_FDCAN_RxFifo1Callback ( hal_fdcan_handle_t * hfdcan , uint32_t rx_fifo1_interrupts )

Rx FIFO 1 callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
void HAL_FDCAN_TxFifoEmptyCallback ( hal_fdcan_handle_t * hfdcan )

Tx FIFO Empty callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

void HAL_FDCAN_TxBufferCompleteCallback ( hal_fdcan_handle_t * hfdcan , uint32_t tx_buffers_idx )

Transmission complete callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
void HAL_FDCAN_TxBufferAbortCallback ( hal_fdcan_handle_t * hfdcan , uint32_t tx_buffers_idx )

Transmission cancellation callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :
void HAL_FDCAN_HighPriorityMessageCallback ( hal_fdcan_handle_t * hfdcan )

High priority message callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

void HAL_FDCAN_TimestampWraparoundCallback ( hal_fdcan_handle_t * hfdcan )

Timestamp wrap around callback.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

void HAL_FDCAN_ErrorCallback ( hal_fdcan_handle_t * hfdcan )

Error callback.

Note

The hfdcan handle’s last_error_codes parameter is updated by the FDCAN processes, and the user can use HAL_FDCAN_GetLastErrorCodes() to verify the most recent error that occurred.

Warning

This weak function must not be modified. When the callback is needed, it must be implemented in the user file.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Error and state functions

group FDCAN_Exported_Functions_Group8

A set of functions allowing to process with the state and last process errors.

Functions

hal_fdcan_state_t HAL_FDCAN_GetState ( const hal_fdcan_handle_t * hfdcan )

Return the FDCAN state.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Current HAL FDCAN state.

uint32_t HAL_FDCAN_GetLastErrorCodes ( const hal_fdcan_handle_t * hfdcan )

Return the FDCAN error code.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Returns :

Last error code. This parameter can be any combination of FDCAN error codes.

Peripheral acquire/release/free the bus

group FDCAN_Exported_Functions_Group9

A set of functions allowing to Acquire/Release the bus based on the HAL OS abstraction layer (stm32_hal_os.c/.h osal):

Functions

hal_status_t HAL_FDCAN_AcquireBus ( hal_fdcan_handle_t * hfdcan , uint32_t timeout_ms )

Acquire the FDCAN bus through the HAL OS abstraction layer (stm32_hal_os.c/.h osal).

Note

HAL_FDCAN_AcquireBus() must be called from thread mode only (not from handler mode i.e from ISR).

Parameters :
  • hfdcan – Pointer to a hal_fdcan_handle_t handle.

  • timeout_ms – Timeout duration in millisecond.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – Semaphore cannot be taken.

hal_status_t HAL_FDCAN_ReleaseBus ( hal_fdcan_handle_t * hfdcan )

Release the FDCAN bus through the HAL OS abstraction layer (stm32_hal_os.c/.h osal).

Note

HAL_FDCAN_ReleaseBus() can be called from thread mode or from handler mode i.e from ISR.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t handle.

Return values :
  • HAL_OK – Operation completed successfully.

  • HAL_ERROR – Semaphore cannot be released.

User data Set/Get

group FDCAN_Exported_Functions_Group10

A set of functions allowing to manage a user data pointer stored to the FDCAN handle:

Functions

void HAL_FDCAN_SetUserData ( hal_fdcan_handle_t * hfdcan , const void * p_user_data )

Set the user data pointer into the handle.

Parameters :
const void * HAL_FDCAN_GetUserData ( const hal_fdcan_handle_t * hfdcan )

Get the user data pointer from the handle.

Parameters :

hfdcan – Pointer to a hal_fdcan_handle_t.

Returns :

Current pointer to the user data.